﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using PccCommonForC;

public partial class Manager_AuthoritySign_AddAuthoritySign : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["AdminUserID"] == null)
        {
            Response.Write("<script language=javascript>alert('Time is out.');window.open('../Default.aspx','_top');</script>");
            return;
        }
        if (!IsPostBack)
            BindData();
    }

    private void BindData()
    {
       if (Request.QueryString["UserID"] != "" && Request.QueryString["UserID"] != null)
        {
            lblDisplay1.Text = "Người dùng: <b>" + Request.QueryString["UserNm"] + "</b>";
            clsWebShop cls = new clsWebShop();
           PccMsg msg=new PccMsg();
           msg.CreateFirstNode("UserID", Request.QueryString["UserID"]);
           DataTable dt = cls.Get_shr_AutUserByCondition(msg.GetXmlStr).Tables[0];
           if (dt.Rows.Count > 0)
           {
               if (dt.Rows[0]["Sign_Mk"].ToString() == "Y")
                   chkSign.Checked = true;
               if (dt.Rows[0]["Print_mk"].ToString() == "Y")
                   chkPrint.Checked = true;
               if (dt.Rows[0]["Review_mk"].ToString() == "Y")
                   chkReview.Checked = true;


           }

        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string schkSign = "N", schkPrint = "N", schkReview="N";
        if (chkSign.Checked == true)
            schkSign = "Y";
        if (chkPrint.Checked == true)
            schkPrint = "Y";
        if (chkReview.Checked == true)
            schkReview = "Y";

        PccMsg msg = new PccMsg();
        msg.CreateFirstNode("UserID", Request.QueryString["UserID"]);
        msg.CreateFirstNode("Sign_mk", schkSign);
        msg.CreateFirstNode("Print_mk", schkPrint);
        msg.CreateFirstNode("Review_mk", schkReview);

        clsWebShop cls = new clsWebShop();
        cls.Ins_Upd_shr_AutUser(msg.GetXmlStr);
        ClientScript.RegisterClientScriptBlock(this.GetType(), "", "<script>alert('Bảo lưu thành công')</script>");
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        Response.Redirect("AuthoritySign.aspx?CodeID="+Request.QueryString["CodeID"]+"");
    }
}
